/*
 * Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
 *
 * Licensed under the Mulan PSL v2.
 * You can use this file according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of the License at
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
 * FOR MORE DETAILS.
 */

#pragma once

#include "DataStructure/Common/Id.h"
#include "DataStructure/Common/Out.h"
#include "DataStructure/Common/Status.h"

#include "DBManager/IRepository/Base/IRepository.h"

/**
 * @brief   : 具有唯一键`id`的表的接口，适用于大部分输入的数据
 * @tparam ClassName
 * @author  : wxc
 * @date    : 2024.10.24
 */
template <typename ClassName>
class IMainlyRepository : public IRepository
{
  public:
    using DataType = ClassName;

    IMainlyRepository () : IRepository ()
    {}

    virtual ~IMainlyRepository () = default;

    /// @brief 获取总数
    /// @return
    virtual std::size_t Size () = 0;

    /// @brief 添加数据
    /// @param entity
    virtual SG::DataStructure::Common::Status Add (ClassName& entity) = 0;

    /// @brief 使用vector批量添加数据
    /// @param entity
    virtual SG::DataStructure::Common::Status Add (std::vector<ClassName>& entity) = 0;

    /// @brief 根据Index获取数据
    /// @param index
    /// @param entityX
    /// @return
    virtual SG::DataStructure::Common::Status FindByIndex (std::size_t index, ClassName& _OUT entity) = 0;

    /// @brief 根据ID获取数据
    /// @param id
    /// @param entity
    /// @return
    virtual SG::DataStructure::Common::Status FindById (SG::DataStructure::Common::Id id, ClassName& _OUT entity) = 0;

    /// @brief 获取所有ID
    /// @return
    virtual std::vector<SG::DataStructure::Common::Id> GetAllId () = 0;

    /// @brief 获取所有数据
    /// @return
    virtual std::vector<ClassName> GetAllData () = 0;

    /// @brief 根据ID获取数量
    /// @param id
    /// @return
    virtual std::size_t Count (SG::DataStructure::Common::Id id) = 0;
};
